<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<ui:composition   xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:ui="http://java.sun.com/jsf/facelets"> 
                  
                  
 	<h:form>                   
            <rich:panel>
                   <f:facet name="header">
                   			Create new ticket
                   			<h:outputText value="Created successfully !" rendered="#{ticketBean.ticketCreated}"/> 
		                   <a4j:status name="panelUpdateStatus">
		                    <f:facet name="start">
		                        (Working, please wait...)
		                    </f:facet>
		                   </a4j:status>
                   </f:facet>
		               
			
<h:panelGrid columns="1" width="100%">
			           
			           
			           
  <h:panelGroup>	
  	           
	<h:panelGrid columns="2" id="panel1"  width="100%">
			                  
		<h:panelGroup >	
			   
			   <h:panelGrid columns="2"  width="50%">
							 
							 <h:outputLabel value="Ticket type" for="type_id"/>
							 <rich:select enableManualInput="false" 
							   			value="#{ticketBean.ticket.ticketType}"
							            id="type_id"
							            defaultLabel="Choose the ticket type" >
							    <f:selectItems value="#{ticketBean.types}"  var="type" itemValue="#{type}" itemLabel="#{type.ticketTypeName}" />
							</rich:select>
							
							
			  	    <h:outputLabel value="Assigned group" for="assigned_group_id"/>
					<rich:select enableManualInput="false" 
					   			  value="#{ticketBean.ticket.assignedGroup}"
					              id="assigned_group_id"
					              converter="#{groupConverter}"
					               >
				    <f:selectItems value="#{ticketBean.groups}"  var="group" itemValue="#{group}" itemLabel="#{group.groupName}" />
				    <a4j:ajax   event="change" execute="@this" listener="#{ticketBean.updateGroupUsers}" render="assigned_used_id"  />
					</rich:select>
					
					
			        <h:outputLabel value="Assigned user" for="assigned_used_id"/>
					 <rich:select enableManualInput="false" 
					   			value="#{ticketBean.ticket.assignedUser}"
					            id="assigned_used_id"
					            defaultLabel="Choose user" >
					    <f:selectItems value="#{ticketBean.groupUsers}"  var="groupuser" itemValue="#{groupuser}" itemLabel="#{groupuser.userName}" />
					</rich:select>
							
							
	
	        
	        </h:panelGrid>
		</h:panelGroup>	 
		  
		<h:panelGroup>	
			<h:panelGrid columns="2" width="50%" >

							 <h:outputLabel value="Issue date" for="issue_date_id"/>       
				           <rich:calendar id="issue_date_id" enableManualInput="false" value="#{ticketBean.ticket.issueDate}" />
				                                  
					          
						<h:outputLabel value="Upload attachments" for="upload_id"/>
					        <h:panelGroup>
					        
				       			 <rich:fileUpload fileUploadListener="#{ticketBean.listener}" id="upload_id" 
				       							  maxFilesQuantity="1"  
				       							  listHeight="100" 
				       							  style="width:200px;" 
				       							  status="panelUpdateStatus"/>
									
								<h:graphicImage alt="" value="resources/img/correct.gif" border="0" rendered="#{not empty ticketBean.ticket.attachedFile}" id="correct_id"/>   		 
					        </h:panelGroup>
							
					        			
							 <h:outputLabel value="Priority" for="priority_id"/>
							 <rich:select enableManualInput="false" 
							   			value="#{ticketBean.ticket.priority}"
							            id="priority_id"
							            defaultLabel="Choose priority" >
							    <f:selectItems value="#{ticketBean.priorities}"  var="per" itemValue="#{per}" itemLabel="#{per.priorityName}" />
							</rich:select>

	        </h:panelGrid>
	</h:panelGroup>
				
	</h:panelGrid>
 </h:panelGroup>
   
               
     <h:panelGroup>        
               
				      <h:panelGrid columns="1" style="align:center;" id="panel2">
				       	
								<h:outputLabel value="Comment" for="comment_id"/>
								<rich:editor id="comment_id" toolbar="basic" value="#{ticketBean.ticket.comments}" style="margin-bottom: 1em" height="150" width="500">
								</rich:editor>     
					  	
					  	
					  	

							
							
				      </h:panelGrid>   
     </h:panelGroup>
               
               
       <h:panelGroup>
            	
					<h:commandButton action="#{ticketBean.insertTicket}" styleClass="button"
					                 value="Submit">
					        <a4j:ajax render="panel1 panel2"  status="panelUpdateStatus"/>
					</h:commandButton>
						
					<h:commandButton  styleClass="button" value="Save" ></h:commandButton>  
					
					<h:commandButton value="Cancel"  action="#{ticketBean.cancelTicket}">
					       <a4j:ajax render="panel1 panel2" status="panelUpdateStatus"/>
					</h:commandButton>		
  	
       </h:panelGroup>   
                  
               
               
               </h:panelGrid>
               
 
        
            </rich:panel>


 </h:form>  
            
</ui:composition>

